import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * historyDataService
 * @date 2019/9/29
 */
import request from "../../../utils/request";
import { parseParameters, getCurrentOrganizationId } from "../../../utils/utils";
import { getEnvConfig } from "../../../utils/iocUtils";

var _getEnvConfig = getEnvConfig(),
    CPAAS_PLATFORM = _getEnvConfig.CPAAS_PLATFORM;
/**
 * @typedef PageQuery<T = any> = {page: {current?: number; pageSize?: number}} & T
 * @property {?number} page.current
 * @property {?number} page.pageSize
 */

/**
 * @typedef HDQuery
 * @property {?string} taskCode - 任务编号
 * @property {?string} serviceName - 所属服务
 * @property {?string} state - 任务状态
 */

/**
 * 分页查询 异步导出历史记录
 * @param {PageQuery<HDQuery>} params - 查询参数
 * @return {Promise<void>}
 */


export function historyDataQuery(_x) {
  return _historyDataQuery.apply(this, arguments);
}
/**
 *
 * @return {Promise<void>}
 */

function _historyDataQuery() {
  _historyDataQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/self/export-task"), {
              method: 'GET',
              query: parseParameters(params)
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _historyDataQuery.apply(this, arguments);
}

export function historyDataCancel(_x2) {
  return _historyDataCancel.apply(this, arguments);
}

function _historyDataCancel() {
  _historyDataCancel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/export-task/cancel"), {
              method: 'PUT',
              query: params
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _historyDataCancel.apply(this, arguments);
}